<?PHP
#
# Author: Cody Sorgenfrey
# copyright South Hill Calvary Chapel 2012
#

include_once("common.php");
include_once("../mysql/common.php");
include_once("../mysql/database_info.php");

function jwplayer_header($file, $id, $width, $height) {
printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/JWMediaPlayer5.5/jwplayer.js'></script>\n");

printf("\t<div id='%s'></div>\n", $id);

printf("<script type='text/javascript'>\n");
printf("jwplayer('%s').setup({\n", $id);
printf("    'id': 'playerID',\n");
printf("    'width': '%d',\n", $width);
printf("    'height': '%d',\n", $height);
printf("    'controlbar': 'bottom',\n");
printf("    'file': 'http://www.southhillcalvary.org%s',\n", $file);
printf("    'modes': [\n");
printf("        {type: 'html5'},\n");
printf("        {type: 'flash', src: './js/JWMediaPlayer5.5/player.swf'},\n");
printf("        {type: 'download'}\n");
printf("    ]\n");
printf("});\n");
printf("</script>\n");
}

$id = $_REQUEST['id'];
$table= $_REQUEST['table'];

connect_select_test($table);
$sermonRaw = mysql_query("SELECT * FROM `" . $table . "` WHERE `id`='" . $id . "'");
$sermon = mysql_fetch_array($sermonRaw);

$title = $sermon['title'];
$meta_key= "Church, Puyallup, SHCC, South Hill, Calvary Chapel, South Hill Calvary Chapel";
$meta_desc= "Teaching at South Hill Calvary Chapel.";
$morehtml=null;
$morejava = null;
$date= $sermon['date'];
$php_time = strtotime($date);
$xml_date = date("l, F jS, Y", $php_time);
$referencedMedia = $sermon['referencedMedia'];

startPage($title, $meta_key, $meta_desc, $morehtml, $morejava);

printf("<div class='sermonInfoBlock'>\n");

printf("\t<p>By: %s</br>\n",$sermon['name']);

printf("\t%s %s</br>\n",$sermon['book'],$sermon['verse']);

printf("\t%s</br></p>\n",$xml_date);

printf("</div>\n\n");

if ($sermon['mfile_video']){
	
	printf("<div class='sermonInfoBlock'><h4>Stream the Video:</h4></div>\n");
	
	printf('<div class="sermonVideo">%s</div>',$sermon['mfile_video']);
	
	printf("&nbsp;");
}


if ($sermon['file']){
	
	printf("<div class='sermonInfoBlock'><h4>Stream the Audio:</h4></div>\n");
	
	if (userIsApple()){
		
		printf("<audio class='sermon' <audio controls='controls'><source src='http://www.southhillcalvary.org%s' type='audio/mpeg' /><source src='http://www.southhillcalvary.org%s' type='audio/ogg' />Your browser does not support the audio element.</audio>\n\n", $sermon['file'], $sermon['file']);
	} 
	else {
		if (userIsTab()) $jwWidth= 700;
		
		else $jwWidth = 300;
		
		jwplayer_header($sermon['file'], "mediaplayer", $jwWidth, 24);
	}

if ($referencedMedia){
	
	printf("<div style='width:%s;'><h4>Referenced Media...</h4>\n", "98%");
	printf("%s", $referencedMedia);
	printf("</div>\n\n");
}

printf("&nbsp;</div>");

}

endPage();


?>

